﻿
function Loading(str,loadingw,loadingh,canClose){
	var bordercolor;
	titleheight=25 //提示窗口标题高度
	bordercolor="#86B9D6";//提示窗口的边框颜色
	titlecolor="#86B9D6";//提示窗口的标题颜色
			
	var sWidth,sHeight;
	sWidth=document.body.offsetWidth+4;
	sHeight=screen.height;

	this.init = function(){
		document.getElementById("loadingBgDiv") ? document.getElementById("loadingBgDiv").parentNode.removeChild(document.getElementById("loadingBgDiv")) : function(){};
		document.getElementById("loadingTitle") ? document.getElementById("loadingTitle").parentNode.removeChild(document.getElementById("loadingTitle")) : function(){};
		document.getElementById("loadingBdDiv") ? document.getElementById("loadingBdDiv").parentNode.removeChild(document.getElementById("loadingBdDiv")) : function(){};
		document.body.oncontextmenu=function(){return false;};
		var bgObj=document.createElement("div");
		bgObj.setAttribute("id","loadingBgDiv");
		bgObj.style.position="absolute";
		bgObj.style.top="0";
		bgObj.style.background="#777";
		//bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75);";
		//bgObj.style.opacity="0.4";
		bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity=60,finishOpacity=100);";
		bgObj.style.left="0";
		bgObj.style.width=sWidth + "px";
		bgObj.style.height=sHeight + "px";
		bgObj.style.zIndex = "10000";
		document.body.appendChild(bgObj);
			
		var loadingObj=document.createElement("div")
		loadingObj.setAttribute("id","loadingBdDiv");
		loadingObj.setAttribute("align","left");
		loadingObj.style.background="white";
		loadingObj.style.border="1px solid " + bordercolor;
		loadingObj.style.position = "absolute";
		loadingObj.style.left = "50%";
		loadingObj.style.top = "50%";
		loadingObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
		loadingObj.style.marginLeft = (-loadingw/2)+"px" ;
		loadingObj.style.marginTop = (-loadingh/2)+document.documentElement.scrollTop+"px";
		loadingObj.style.width = loadingw + "px";
		loadingObj.style.height = loadingh + "px";
		loadingObj.style.textAlign = "left";
		loadingObj.style.lineHeight ="25px";
		loadingObj.style.zIndex = "10001";
   
		var title=document.createElement("h4");
		title.setAttribute("id","loadingTitle");
		title.setAttribute("align","right");
		title.style.margin="0";
		title.style.padding="3px";
		title.style.background=bordercolor;
		title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
		title.style.opacity="0.75";
		title.style.border="1px solid " + bordercolor;
		title.style.height="18px";
		title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
		title.style.color="white";
		title.style.cursor="pointer";
		if (canClose==1){
			title.innerHTML="关闭";
			title.onclick=function(){
				document.body.oncontextmenu=function(){return true;};
				document.getElementById("loadingBgDiv").style.display = "none";
				document.getElementById("loadingTitle").style.display = "none";
				document.getElementById("loadingBdDiv").style.display = "none";
			}
		}
  		//不可自行关闭
		else
		{
			title.innerHTML="";
		}
		document.body.appendChild(loadingObj);
		document.getElementById("loadingBdDiv").appendChild(title);
		var txt=document.createElement("p");
		txt.style.margin="1em 0"
		txt.setAttribute("id","loadingTxt");
		txt.innerHTML=str;
		document.getElementById("loadingBdDiv").appendChild(txt);
	}
	this.reset = function(){
		document.body.oncontextmenu=function(){return true;};
		document.getElementById("loadingBgDiv").style.display = "none";
		document.getElementById("loadingTitle").style.display = "none";
		document.getElementById("loadingBdDiv").style.display = "none";
	}
}